package image;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
/**Class to read or write settings*/
public class Settings {
	public static void writeSettings() {
		File settings = new File("settings.txt");
		
		PrintWriter pw = null;
		try {
			pw = new PrintWriter(settings);
			
			String out;
			
			out = Arrays.toString(ImageMain.minValue);
			out = out.substring(1, out.length()-1);
			pw.println(out);
			
			out = Arrays.toString(ImageMain.minSaturation);
			out = out.substring(1, out.length()-1);
			pw.println(out);
			
			pw.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static void readSettings() throws IOException {
		File settings = new File("settings.txt");
		System.out.println("Settings: "+settings.exists());
		if(settings.exists()) {
			BufferedReader br = new BufferedReader(new FileReader(settings));
			
			String in;
			
			in = br.readLine();
			ImageMain.minValue = TypeParser.parseIntArray(in, ImageMain.minValue, 4);
			System.out.println(Arrays.toString(ImageMain.minValue));
			in = br.readLine();
			ImageMain.minSaturation = TypeParser.parseIntArray(in, ImageMain.minSaturation, 4);
			
			br.close();
		}
		
	}

}
